package com.ruozedata.bigdata.homework.homework03

object wordCount {
    def main(args: Array[String]): Unit = {
        val words = List(
              "hello", "hi", "high", "hhh", "heiheihei", "pk"
            , "person", "professional", "zoo", "zookeeper"
            , "hbase", "flink", "flume", "hadoop"
        )

        //wc[w不是单词，而是单词中的字母，单词中重复的只算一次]
        // step 1 每个单词中字母去重，并将所有独立的字母转换成set
        // step 2 所有单词的字母分组并count计数
        println(
            words.flatMap(x => x.toList.toSet)
                 .groupBy(x => x)
                 .mapValues(_.size)
                 .toList
                 .sortBy(_._2)
        )


    }
}
